package demo.android.com.mvpdemo.mvp2;

import demo.android.com.mvpdemo.mvp2.base.BasePresenter;
import demo.android.com.mvpdemo.retrofit.BaseSubscriber;
import demo.android.com.mvpdemo.retrofit.UserInfo;

/**
 * Created by Vya on 2018/1/3 0003.
 */

public class UserInfoPresenter extends BasePresenter<UserInfoContract.UserInfoView,UserInfoModel> implements UserInfoContract.UserInfoPresenter {

    //肯定会持有Model和View, 父类创建了

    @Override
    public void getUsers(String token) {
        //使用网络引擎获取数据
            getView().onLoading();

       getModel().getUser(token).subscribe(new BaseSubscriber<UserInfo>() {
            @Override
            protected void onError(String errorCode, String errorMessage) {
                getView().onError();
            }

            @Override
            public void onNext(UserInfo userInfo) {
                getView().onSucceed(userInfo);
            }
        });
    }
}
